<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Cases extends Model
{
    protected $table = 'case';
    protected $primaryKey = 'id';
    public $timestamps = false;
    protected $guarded = ['id'];   //不可写入字段

    public static function getList($category, $page)
    {
        $per = 10; # 每页记录数
        $case = self::select('*')->where('status', 1);
        if ($category > 0) {
            $case->where('category', $category);
        }
        $case->orderBy('rank', 'desc')->orderBy('update_time', 'desc');
        if ($page > 1) {
            $case->skip($page * $per - $per);
        }
        return $case->take($per)->get();
    }
}
